package com.bw.test;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomUtils {

    public static void main(String[] args) {
        System.out.println(getRandomNum());
        System.out.println(getrandomNum1());
        System.out.println(getRandomNum2());
        System.out.println(getRandomNum3());
    }

    //获取一个随机正整数
    public static int getRandomNum(){
        Random random = new Random();
        return random.nextInt(Integer.MAX_VALUE);
    }
    //获取一个90以内的正整数
    public static int getrandomNum1(){
        Random random = new Random();
        return random.nextInt(90);
    }

    //获取一个在60-100以为的正整数
    public static int getRandomNum2(){
        Random random = new Random();
        return 60+random.nextInt(40);
    }
    //获取20个在50-300以内的正整数
    public  static List<Integer> getRandomNum3(){
        ArrayList<Integer> list = new ArrayList<>();
        for (int i=0;i<20;i++){
            Random random = new Random();
            int num = 50+random.nextInt(250);
            list.add(num);
        }
        return list;
    }
}
